
function coosmenu(parentElement)
{
	this.config = {
		target			: null,
		folderLinks		: true,
		useSelection	: true,
		useLines		: false,
		useIcons		: false,
		imagePath		: "../images/coos/menu/"
	};
	this.icon = {
	};
	this.nodes = coos.hashmap();
	this.parentEl = coos.$obj(parentElement) || document.body;
	this.root = null;
}
function coosmenuNode(parentEl,id, pid, name, url, title, target, islast, icon, iconOpen, open)
{
	if(!parentEl){return false;}
	this.parentEl = parentEl;
	this.id = id;
	this.pid = pid;
	this.name = name;
	this.url = url;
	this.title = title;
	this.islast = islast;
	this.icon = icon;
	this.iconOpen = iconOpen;
	this.open = open;
	if(target == null || target == "null" || target == "")
	{
		this.target = "";
	}
	else
	{
		this.target = " target=\"" + target + "\" ";
	}
	var html = "";
	if(this.pid == -1)
	{
		html = '<div class="coosmenuDiv"><ul id="menu_' + this.id + '"></ul></div>';
	}
	else if(islast == 1){
		html = '<li><a href="' + this.url + '"' + this.target + '>' + this.title + '</a></li>';
	}
	else{
		html = '<li onmouseover="coosmenu.show(this);" onmouseout="coosmenu.hidden(this)"><a href="' + this.url + '"' + this.target + '>' + this.title + '</a>' + '<ul id="menu_' + this.id + '"></ul></li>';
	}
	coos.$insert("bottom",parentEl,html);
}
coosmenu.prototype.add = function(id, pid, name, url, title, target, islast, icon, iconOpen, open)
{
	var parentEl = null;
	if(pid == -1){
		parentEl = this.parentEl;
	}else{
		parentEl = coos.$id("menu_" + pid);
	}
	this.nodes.set(id,new coosmenuNode(parentEl,id, pid, name, url, title, target, islast, icon, iconOpen, open));
};
coosmenu.show = function(li)
{
	li.getElementsByTagName("ul")[0].style.display = "block";
};
coosmenu.hidden = function(li)
{
	li.getElementsByTagName("ul")[0].style.display = "none";
};
